package com.phuonghoang.vnexpress;

import java.util.List;

import com.phuonghoang.adapter.NewAdapter;
import com.phuonghoang.model.RssItem;
import com.phuonhoang.utils.Variables;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

public class NewListVnexpressActivity extends ListActivity {
private List<RssItem>items;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		Bundle bundle = getIntent().getExtras();
		int catergorie = bundle.getInt(Variables.CATEGORIE);
		int paper = bundle.getInt(Variables.PAPER);
		setTitle(Variables.CATEGORIES[paper][catergorie]);
		int key = paper*1000+catergorie;
		items=Variables.newMap.get(key);
		if (items==null) {
			Toast.makeText(getBaseContext(), "This is no connect Internet", Toast.LENGTH_LONG).show();
		}
		else
		{
		NewAdapter adapter = new NewAdapter(this, Variables.ICONS[paper],items);
		setListAdapter(adapter);
		}
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		Intent intent = new Intent(this,NewAcitivty.class);
		intent.putExtra(Variables.LINK, items.get(position).getLink());
		startActivity(intent);
	}

}
